home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / Documentation / Engineering Notes / Miscellaneous / Menu Resources < prev    next >
Encoding:
Text File  |  1996-04-26  |  2.6 KB  |  64 lines  |  [TEXT/ttxt]

  1. OpenDoc
  2. Development
  3. Framework
  4.                                                                                                                                                                                      
  5. Menu Resources 
  6. ODF Release 1                                                                                                                                                             
  7.  
  8. ODF provides an easy way to create your  part's menu bar in a cross-platform manner. 
  9.  
  10. To add a menubar to your part:
  11.  
  12. • Create a text file with the extension .fr containing your menubar definition (see the syntax below).
  13.  
  14. • Add this file to your project (if you are using Code Warrior) or to your MacMake.bmk file if you are using an MPW-based compiler.
  15.  
  16. • In your part's Initialize method (override of FW_CPart::Initialize) call:
  17.  
  18.                             GetMenuBar(ev)->InitializeFromResource(ev, <Your MenuBar resource ID>);
  19.  
  20. • Don't forget to use the macro FW_DO_NOT_DEAD_STRIP if your menus contain toggle items or submenu items. ODF automatically calls this macro for text items and separator items but not for toggle and submenu items.
  21.  
  22. The following menubar definition will create a menubar with two pulldown menus (Menu1 and Menu2). The first pulldown menu has six items (counting the two separator items) and the second one has two. The first pulldown menu also has a submenu.
  23.  
  24. resource FW_RMenuBar(kMenuBar)
  25. {
  26.             {
  27.                         FW_RPullDownMenu
  28.                         (
  29.                                         "Menu1"
  30.                                         {
  31.                                                         FW_RTextItem(cCommand1, 'F', "Text Item 1"),
  32.                                                         FW_RTextItem(cCommand2,  FW_kNoKeyEquivalent, "Text Item 2"),
  33.                                                         FW_RSeparatorItem(),
  34.                                                         FW_RSubMenuItem
  35.                                                         (
  36.                                                              "SubMenu"
  37.                                                              {
  38.                                                                   FW_RTextItem(cCommand3,  FW_kNoKeyEquivalent, "Text Item 3"),
  39.                                                                   FW_RTextItem(cCommand4,  FW_kNoKeyEquivalent, "Text Item 4"),
  40.                                                              }
  41.                                                         ),
  42.                                                         FW_RSeparatorItem(),
  43.                                                      FW_RToggleItem(cCommand5,  FW_kNoKeyEquivalent, "Hide", "Show"),
  44.                                     }
  45.                     ),
  46.                     FW_RPullDownMenu
  47.                     (
  48.                                         "Menu2"
  49.                                         {
  50.                                                         FW_RTextItem(cCommand6, 'R', "Text Item 6"),
  51.                                                         FW_RTextItem(cCommand7,  FW_kNoKeyEquivalent, "Text Item 7"),
  52.                                      }
  53.                 )
  54.             }
  55. };
  56.  
  57. • The convention used by ODF is to put constants used in both .fr resource files and C++ files into a file called "Defines.k".
  58.  
  59. #define    kMenuBar    1024
  60. #define cCommand1    FW_kFirstUserCommandID
  61.  
  62.  
  63. © 1993 - 1996 Apple Computer, Inc. All rights reserved.
  64. Apple, the Apple Logo, Macintosh, and OpenDoc are trademarks of Apple Computer, Inc., registered in the United States and other countries.